<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of YouSupplier
 *
 * @author fabiano
 */
require_once SITE_ROOT_PATH.'/_lib/classes/model/MasterSupplier.php';
require_once SITE_ROOT_PATH.'/_lib/classes/Supplier/low/class.QueryBuilder.php';
require_once SITE_ROOT_PATH.'/_lib/base/curl_multirequest.php';

class YouSupplier extends MasterSupplier{    
    
    public function doBooking(){
        // don't do anything yet but it has to be here just because the Supplier class is abstract        
    }
    public function doCancelBooking(){
        // don't do anything yet but it has to be here just because the Supplier class is abstract        
    }       
    public function buildBookingXML($params){
       // don't do anything yet but it has to be here just because the Supplier class is abstract 
    }
    public function buildCancelXML($params){
       // don't do anything yet but it has to be here just because the Supplier class is abstract
    }
    public function sendBookingRequest(){
        // don't do anything yet but it has to be here just because the Supplier class is abstract
    }
    
    public function buildSearchXML($params){        
        $search_query = ''; 
        $params = $this->mapSearchParams($params);
        $uri_params = array();
        $uri_params[] = $this->auth["username_name"]."=".$this->auth["username_value"];
        $uri_params[] = $this->auth["password_name"]."=".$this->auth["password_value"];
        foreach ($params as $param=>$value) {
                $uri_params[] = "$param=$value";
        }
        $search_query = $this->setXmlSearch($this->getServiceUrlByKey("search")."?".implode("&", $uri_params));

    }    
    
    public function sendSearchRequest(){     
        $hash = md5($this->getXmlSearch());
        if(isset($_SESSION[$hash])) 
           $result = $_SESSION[$hash];
        else {
          $result = curl_multirequest($this->getXmlSearch());
          $_SESSION[$hash] = $result;
        }
        return $result;        
    }        
    
      
    
}

?>
